package com.yiwei.zxp.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yiwei.zxp.R;
import com.yiwei.zxp.activity.BussinessOrderDetailActivity;
import com.yiwei.zxp.activity.ShowImagesActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class CommentPhotoAdapter extends ItemAdapter<String, CommentPhotoAdapter.DefaultHolder> {


    private Context context;
    private String order_no;

    public void setOrder_no(String order_no) {
        this.order_no = order_no;
    }

    public CommentPhotoAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_comment_photo, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        Glide.with(context).load(getItem(position)).asBitmap().centerCrop().into(holder.imgGoods);
        if (position == 0) {
            holder.viewLeft.setVisibility(View.VISIBLE);
        } else {
            holder.viewLeft.setVisibility(View.GONE);
        }
        holder.imgGoods.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ShowImagesActivity.class);
                intent.putStringArrayListExtra("data", (ArrayList<String>) getmSource());
                intent.putExtra("currentPosition", position);
                context.startActivity(intent);
            }
        });
    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.view_left)
        View viewLeft;
        @BindView(R.id.img_goods)
        ImageView imgGoods;

        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
